package vip.zhenzicheng.design_patterns.singleton;

import java.io.IOException;
import java.io.InputStream;

/**
 * Runtime采用了单例模式 打印windows中ip地址信息
 *
 * @author zhenzicheng
 * @date: 2022-05-25 10:43
 * @see Runtime#getRuntime()
 */
public class RuntimeDemo {

  public static void main(String[] args) throws IOException {
    Runtime runtime = Runtime.getRuntime();

    // 执行命令
    Process process = runtime.exec("ipconfig");
    // 获取输入流
    InputStream is = process.getInputStream();
    // 一次性读取数据 10KB
    byte[] arr = new byte[1024 * 1024 * 100];
    arr = is.readAllBytes();
    // 将字节数组转字符串
    System.out.println(new String(arr, "GBK"));

  }
}
